package tech.yunland.shop.domain.dao;

import com.moyuer.bsf.domain.dao.BaseDao;

import tech.yunland.shop.domain.model.GoodsPackage;
import tech.yunland.shop.domain.model.GoodsPackageEntry;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;


/**
 * @author: 袁首京<yuanshoujing@gmail.com>
 * 16/4/14
 */
@Repository
public class GoodsPackageEntryDao extends BaseDao<GoodsPackageEntry, String> {
	
	
	/**
	 * 获取优惠活动分录
	 * 
	 * @param goodsPackage
	 * @return
	 */
	public Set<GoodsPackageEntry> getPackageEntry(GoodsPackage goodsPackage){
		
		DetachedCriteria criteria = DetachedCriteria.forClass(GoodsPackageEntry.class);
		criteria.createCriteria("owner").add(Restrictions.idEq(goodsPackage.getId()));
		List<GoodsPackageEntry> packageEntry =this.findByCriteria(criteria);
		
		Set<GoodsPackageEntry> setPackageEntry=new HashSet<GoodsPackageEntry>();
		setPackageEntry.addAll(packageEntry);
		
		return setPackageEntry;
		
	}
	
	
}
